package com.hicorp.segment.service.impl;

import com.hicorp.segment.mapper.QueryMapper;
import com.hicorp.segment.pojo.query.QueryBy;
import com.hicorp.segment.pojo.query.QueryResult;
import com.hicorp.segment.service.QueryService;
import com.hicorp.segment.utils.ResultBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("queryService")
@Slf4j
public class QueryServiceImpl implements QueryService {
    @Resource
    private QueryMapper queryMapper;

    @Override
    public ResultBean<List<QueryResult>> queryBy(String tableName, QueryBy queryBy) {
        try {
            List<QueryResult> queryResultList = queryMapper.queryBy(queryBy);
            return new ResultBean<>(queryResultList);
        } catch (Exception e) {
            log.error(e.getMessage());
            return new ResultBean<>(400,"查询异常");
        }

    }
}
